{extends file="base.html"}

{extends file="base.html"}

{block name="lunbo"}
	<div class="row hidden-xs">
		<div class="col-md-3">
			<img class="img-responsive" src="./public/images/11.jpg" />
		</div>
		<div class="col-md-3">
			<img class="img-responsive" src="./public/images/22.jpg" />
		</div>
		<div class="col-md-3">
			<img class="img-responsive" src="./public/images/33.jpg" />
		</div>
		<div class="col-md-3">
			<img class="img-responsive" src="./public/images/22.jpg" />
		</div>
	</div>
{/block}

{*主体*}
{block name="content"}
	<!-- 当前页 -->
	<h2 class="news-tit place-tit">
		<i class="glyphicon glyphicon-grain"></i><span>当前位置 : </span><a href="index.php">主页</a> > <a href="index.php?a=blist">get新技能</a>><a href="">又是美好的一天</a>
	</h2>
	<article>
		<h1 class="title">{$con.title}</h1>
		<div class="info">
			<small>时间:</small>{$con.addtime|date_format:"%Y-%m-%d %H:%M:%S"}
			<small>栏目:</small><a href="#">{$con.kid}</a>
			<small>作者:</small><a href="#">{$con.author}</a>
			<small>点击:</small> {$con.clicks}
		</div>
		<div class="intro" hidden>
			{$con.abstract}
		</div>
		<div class="content"> 
			<p>{$con.content}</p>
		</div>	
		<div class="keywords"><span>关键字: </span>{$con.keyword}</div>

	</article>
	<!-- 引导 -->
	<div class="art-items">
		<div class="preNext"><span>上一篇: </span>
			{if $pre == 0}
				已经是第一篇了
			{else}
				<a href="index.php?a=content&id={$pre['id']}">{$pre['title']}</a>
			{/if}
		</div>
		<div class="preNext"><span>下一篇: </span>
			{if $next == 0}
				已经是最后一篇了
			{else}
				<a href="index.php?a=content&id={$next['id']}">{$next['title']}</a>
			{/if}
		</div>
	</div>
	<!-- 评论start -->
	<div class="panel panel-default">
	  <div class="panel-heading">发表评论</div>
	  <div class="panel-body">
	  	<form name="myform" onsubmit="return doSubmit(0,0,1,{$con.id});">
			<textarea id="L_content" name="content" 
                        placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 100px;">{$art.content}</textarea>
            <input type="submit" value="发表" style="background-color:#099;border:0;width:90px;height:30px;float:right;margin-right:15px;margin-top:5px;">
	  	</form>
	  </div>
	</div>
	<!-- 评论内容 -->
	<div class="panel panel-default">
	  <div class="panel-heading">评论</div>
	  <div class="panel-body" id="mycommment">
	  		{if count($comment)<1}
	  			<h4 id="myfirstcom">还没有人评论，快来抢占第一个沙发！</h4>
	  		{else}
			{foreach $comment as $com}
			<div class="row" style="padding:5px;border-bottom:3px solid #e6e6e6;margin-bottom:5px;">
				<div class="col-md-2">
					<a href="index.php">
						<img class="img-responsive" src="./public/images/11.jpg" />
					</a>
				</div>
				<div class="col-md-10" id="pinlunqu{$com.id}">
					<div id="shouping">
					<p id="username"><a  style="font-size:12px;color:red;"  href="#" >静候花开</a></p>
					<p style="color:#333;" id="pcontent">{$com.content}</p>
					<p class="autor" style="margin-bottom:16px;">
						<a href="#" id="date" class="pinlun" style="margin-left:0px;">{$com.addtime|date_format:"%Y-%m-%d"}</a>
						<a  id="huifu" onclick="huifu({$com.id},{$com.uid})" href="javascript:;" class="pinlun"><i class="glyphicon glyphicon-comment"></i>回复</a>
						<a href="#"  class="pinlun"><i class="glyphicon glyphicon-heart"  ></i>顶</a>
						<a href="#"  class="pinlun"<i class="glyphicon glyphicon-share-alt"></i>转发</a>
						<a href="#"  class="pinlun"><i class="glyphicon glyphicon-flag"></i>举报</a>
					</p> 
					</div>
					<!-- 回复评论 -->
					<div id="huifuqu" aa="{$com.id}"></div>
					<!-- <div class="row" style="padding:5px;border-top:2px solid #e6e6e6;margin-bottom:5px;">
						<div class="col-md-2">
							<a href="index.php">
								<img class="img-responsive" src="./public/images/11.jpg" />
							</a>
						</div>
						<div class="col-md-10" id="pinlunqu{$com.id}">
							<p id="username"><a  style="font-size:12px;color:red;"  href="">静候花开</a></p>
							<p style="color:#333;" id="pcontent">{$com.content}</p>
							<p class="autor" style="margin-bottom:16px;">
								<a href="#" id="date" class="pinlun" style="margin-left:0px;">{$com.addtime|date_format:"%Y-%m-%d"}</a>
								<a  id="huifu" onclick="huifu({$com.id},{$com.uid})" href="javascript:;" class="pinlun"><i class="glyphicon glyphicon-comment"></i>回复</a>
								<a href="#"  class="pinlun"><i class="glyphicon glyphicon-heart"  ></i>顶</a>
								<a href="#"  class="pinlun"<i class="glyphicon glyphicon-share-alt"></i>转发</a>
								<a href="#"  class="pinlun"><i class="glyphicon glyphicon-flag"></i>举报</a>
							</p> 	
						</div>
					</div>			 -->
				</div>
			</div>
			{/foreach}
			{/if}
	  </div>
	</div>
	{literal}
		<script type="text/javascript">
		//添加评论
		function doSubmit(sort,cid,uid,aid){		
				var content = $("textarea[name='content']").val();
				var path = aid+","+cid+","+cid;
				$.ajax({
                    type:'post',             //请求方式
                    url :'index.php?a=comment',           //ajax请求地址
                    data:"sort="+sort+"&cid="+cid+"&aid="+aid+"&uid="+uid+"&path="+path+"&content="+content, //请求传递的参数
                    dataType:'json',        //预期服务器返回的数据类型
                    async : true,           //是否异步
                    success: function(data){
                        if (data!=0) {
                        	$("#myfirstcom").remove();

                        	var str = "<div class='row' style='padding:5px;border-bottom:3px solid #e6e6e6;margin-bottom:5px;'><div class='col-md-2'><a href='index.php'><img class='img-responsive' src='./public/images/11.jpg' /></a></div>";
                        	str += "<div class='col-md-10'id='pinlunqu"+data.id+"'><h4 id='username'><a  style='font-size:12px;color:red;'  href=''>静候花开</a></h4>";
                        	str += "<p style='color:#333;' id='pcontent'>"+data.content+"</p>";
                        	str += "<p class='autor' style='margin-bottom:16px;'><a href='#' id='date' class='pinlun' style='margin-left:0px;'>"+data.time+"</a><a href='javascript:;' id='huifu'  class='pinlun' onclick='huifu("+data.id+",1)'><i class='glyphicon glyphicon-comment'></i>回复</a><a href='#'  class='pinlun'><i class='glyphicon glyphicon-heart'  ></i>顶</a><a href='#'  class='pinlun'<i class='glyphicon glyphicon-share-alt'></i>转发</a><a href='#'  class='pinlun'><i class='glyphicon glyphicon-flag'></i>举报</a></p> ";
                        	str += "</div></div>";						
							$("#mycommment").prepend(str);
							$("textarea[name='content']").val('');
                        }else{
                        	alert("评论失败");
                        }
                    },  //ajax成功后的回调函数
                    error : function(){
                        alert("ajax请求失败！");
                    }   //ajax失败后的回调函数
                });
             	return false;
             }
             
            //弹出回复框
            function huifu(pid,uid){
             	$("#pinlunqu"+pid).append("<div id='replyKuang'><form name='myform1'  onsubmit='return doSub("+pid+","+uid+");'><textarea id='L_content' name='cont'   placeholder='请输入内容' class='layui-textarea fly-editor' style='height: 100px;'></textarea><input type='submit' value='回复' style='background-color:#099;border:0;width:90px;height:30px;float:right;margin-right:15px;margin-top:5px;'></form></div>");
             }

            //执行回复评论
            function doSub(pid,uid){
            	var content = $("textarea[name='cont']").val();
            	 //alert(content);
            	 $.ajax({
            	 	type:"post",
            	 	url:"index.php?a=replyCom",
            	 	data:"content="+content+"&pid="+pid+"&uid="+uid,
            	 	dataType:"json",
            	 	success:function (data) {
            	 		if (data!=0) {
            	 			var str = "<div class='row' style='padding:5px;border-top:2px solid #e6e6e6;margin-bottom:5px;'><div class='col-md-2'><a href='index.php'><img class='img-responsive' src='./public/images/11.jpg' /></a></div>";
                       		str += "<div class='col-md-10'id='pinlunqu"+data.id+"'><p id='username'><a  style='font-size:12px;color:red;'  href=''>静候花开</a></p>";
                         	str += "<p style='color:#333;' id='pcontent'>"+data.content+"</p>";
                         	str += "<p class='autor' style='margin-bottom:16px;'><a href='#' id='date' class='pinlun' style='margin-left:0px;'>"+data.addtime+"</a><a href='javascript:;' id='huifu'  class='pinlun' onclick='huifu("+data.id+",1)'><i class='glyphicon glyphicon-comment'></i>回复</a><a href='#'  class='pinlun'><i class='glyphicon glyphicon-heart'  ></i>顶</a><a href='#'  class='pinlun'<i class='glyphicon glyphicon-share-alt'></i>转发</a><a href='#'  class='pinlun'><i class='glyphicon glyphicon-flag'></i>举报</a></p> ";
                        	str += "</div></div>";
                        	$("#pinlunqu"+data.pid).append(str);
                         	$("#replyKuang").css("display","none") ;
                         }
            	 	},
            	 	error:function () {
            	 		alert("请求数据错误！");
            	 	}

            	 });
            	 return false;
            }
            
            replyShow();
            //显示回复评论
            function replyShow() {
            	// var pid = new Array();
            	pid = $("#huifuqu").attr("aa");
            	//console.log(pid);
            	$.ajax({
            		type:"post",
            	 	url:"index.php?a=replyShow",
            	 	data:"pid="+pid,
            	 	dataType:"json",
            	 	success:function (data) {
            	 		console.log(data);
            	 		if (data!=0) {
            	 			var d = data[0];
            	 			for(var i=0;i<d.length;i++){
            	 				var str = "<div class='row' style='padding:5px;border-top:2px solid #e6e6e6;margin-bottom:5px;'><div class='col-md-2'><a href='index.php'><img class='img-responsive' src='./public/images/11.jpg' /></a></div>";
                       			str += "<div class='col-md-10'id='pinlunqu"+d[i].id+"'><p id='username'><a  style='font-size:12px;color:red;'  href=''>静候花开</a></p>";
                         		str += "<p style='color:#333;' id='pcontent'>"+d[i].content+"</p>";
                         		str += "<p class='autor' style='margin-bottom:16px;'><a href='#' id='date' class='pinlun' style='margin-left:0px;'>"+d[i].addtime+"</a><a href='javascript:;' id='huifu'  class='pinlun' onclick='huifu("+d[i].id+",1)'><i class='glyphicon glyphicon-comment'></i>回复</a><a href='#'  class='pinlun'><i class='glyphicon glyphicon-heart'  ></i>顶</a><a href='#'  class='pinlun'<i class='glyphicon glyphicon-share-alt'></i>转发</a><a href='#'  class='pinlun'><i class='glyphicon glyphicon-flag'></i>举报</a></p> ";
                        		str += "</div></div>";

                        		$("#huifuqu").append(str);
                          }
                      }
            	 	},
            	 	error:function () {
            	 		
            	 	}

            	 });
            	
            }
        </script>
	{/literal}

{/block}

{*侧边栏*}
{block name="aside"}
	<!-- 标签（3） -->
	<div class="panel panel-default margin-top">
		<!-- Default panel contents -->
		<div class="panel-heading">热门标签</div>
		<ul class="list-group">
			<li class="list-group-item">
			{foreach $tag as $t}
			<h4 class="tag"><a href="index.php?a=tlist&t={$t.id}"><span class="label label-info">{$t.name}</span></a></h4>
			{/foreach}
			</li>
		</ul>
	</div>
	<!-- 热门推荐 -->
	<div class="panel panel-default margin-top">
	    <div class="panel-heading">热门推荐</div>
	    <div class="panel-body">
	        <ul class="nav nav-tabs" id="myTab"> 
		      <li class="active"><a href="#home" data-toggle='tab'>最热</a></li> 
		      <li><a href="#jishu" data-toggle='tab'>技术</a></li> 
		      <li><a href="#life" data-toggle='tab'>生活</a></li>  
		    </ul> 
		       
		    <div class="tab-content"> 
		      <div class="tab-pane active" id="home">
					<ul class="list-group">
						{foreach $hot as $h}
		  				<li class="list-group-item">
		  					<a href="index.php?a=content&id={$h.id}" style="color:#272a30;" >
		  					<span class="glyphicon glyphicon-fire" aria-hidden="true">{$h.title}
		  					</span>
		  					</a>
		  				</li>
						{/foreach}
		  			</ul>
		      </div> 
		      <div class="tab-pane" id="jishu">
					<ul class="list-group">
						{foreach $jishuhot as $jh}
		  				<li class="list-group-item">
		  					<a href="index.php?a=content&id={$jh.id}" style="color:#272a30;" >
		  						<span class="glyphicon glyphicon-fire" aria-hidden="true">{$jh.title}
		  						</span>
		  					</a>
		  				</li>
						{/foreach}
		  			</ul>
		      </div> 
		      <div class="tab-pane" id="life">
					<ul class="list-group">
						{foreach $lifehot as $lh}
		  				<li class="list-group-item">
		  					<a href="index.php?a=content&id={$lh.id}" style="color:#272a30;" >
		  						<span class="glyphicon glyphicon-fire" aria-hidden="true">{$lh.title}
		  						</span>
		  					</a>
		  				</li>
						{/foreach}
		  			</ul>
		      </div> 
		    </div> 
	    </div>
    </div>
	<!-- 最新文章 -->
	 <div class="panel panel-default margin-top">
		<!-- Default panel contents -->
		<div class="panel-heading">最新文章</div>
		<ul class="list-group">
		  {foreach $new as $n}
		  	<li class="list-group-item"><a href="index.php?a=content&id={$n.id}" style="color:#272a30;" ><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>{$n.title}</a></li>
		  {/foreach}
		</ul>
	</div>
	
	<!-- 联系博主 -->
	
	<!-- 友情推荐 -->

{/block}
{block name="js"}
	
{/block}